package com.ymatou.iapi.trading.operate.service;

import java.util.HashMap;
import java.util.Map;

import org.json.JSONException;
import org.json.JSONObject;

import com.google.gson.reflect.TypeToken;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.EnvSetup;

/**
 * 批量退货退款申请效验接口Call FreeMaker Template自动生成代码
 */
public class BatchValidateRefundCall extends YmatouBaseCall {
	private static String opurl = "api/SalesRefund/ApplyValidationList";

	public BatchValidateRefundCall() {
		super(EnvSetup.getSystemUrl("operate_iapi"), opurl, "POST", "JSON");
	}

	@Override
	public void addDefHeader() {
		client.addHeader("Accept",
				"text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}

	//
	public JSONObject getData() {
		JSONObject data = null;
		try {
			data = new JSONObject(getReturnData()).getJSONObject("data");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return data;
	}

	// OrderOperationInfo 下type值
	public Map<String, Object> getRespMap() {

		Map<String, Object> map = new HashMap<String, Object>();
		try {

			map = (Map<String, Object>) FormatUtil.GSONToObject(getData()
					.getString("respMap"),
					new TypeToken<HashMap<String, Object>>() {
					}.getType());

		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return map;
	}
}
